package demo;

import org.springframework.beans.BeanUtils;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class demo1 {

    public static void main(String[] args) {
        Person1 p1 = new Person1();
        p1.setAge(18);
        p1.setName("zhangsan");

        Person2 p2 = new Person2();
        // org.springframework.beans.BeanUtils
        BeanUtils.copyProperties(p1, p2);

        System.out.println(p2.toString()); // Person2{name='zhangsan', age='null'}
    }
}


class Person1 {
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

class Person2{
    private String name;
    private String age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person2{" +
                "name='" + name + '\'' +
                ", age='" + age + '\'' +
                '}';
    }
}


